// Author: Zhang Yisong(zhang_yisong@foxmail.com)

#pragma once

#include "awaitable.hpp"
#include "pw_async2/dispatcher.h"
#include <span>
#include <type_traits>
namespace coro {

class Dispatcher : public pw::async2::Dispatcher {
public:
  Dispatcher() = default;
  template <typename... TTasks>
    requires std::conjunction_v<std::is_base_of<pw::async2::Task, TTasks>...>
  auto Post(TTasks &...tasks) -> void {
    (pw::async2::Dispatcher::Post(tasks), ...);
  }
  auto Post(std::span<coro::Coro> entries) -> void {
    for (auto &task : entries) {
      this->Post(task);
    }
  }
};

} // namespace coro